<admintpl file="header" />

</head>

<body>
<div class="wrap js-check-wrap">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a href="{:U('Message/Index')}">留言墙</a></li>
            <li><a href="{:U('Message/addwall')}">创建留言墙</a></li>
            <!--<li><a href="{:U('Message/manage')}">留言管理</a></li>-->
            <!--<li><a href="{:U('Message/addmessage')}">创建留言</a></li>-->
        </ul>
        <form class="form-horizontal js-ajax-form" action="{:U('Message/Index')}" method="post">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th>名称</th>
                    <th>创建时间</th>
                    <th>URL</th>
                    <th>状态</th>
                    <th>设置观众数</th>
                    <th>设置留言数</th>
                    <th>添加留言数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="list" item="vo">
                    <tr>
                        <td><a href='{:U("Admin/Message/editwall",array("wall_id"=>$vo["id"]))}'>{$vo.title}</a></td>
                        <td>{$vo.create_time}</td>
                        <td><input  id="foo_{$vo['id']}" value="{$vo.url}" style="width: 250px;">
                            <if condition="$vo.url neq '' ">
                                <a href="#" onclick="copyone({$vo['id']})" class="btn_{$vo['id']}" data-clipboard-target="#foo_{$vo['id']}" aria-label="复制成功！">复制</a>
                            </if>
                        </td>
                        <td><if condition="$vo.status eq 0 ">未开始<elseif condition="$vo.status eq 1 "/> 已开始<else />已结束</if> </td>
                        <td>{$vo.set_view_count}</td>
                        <td>{$vo.set_mes_count}</td>
                        <td>{$vo.message_count}</td>
                        <td>
                            <a href='#' onclick="editmember({$vo['id']},{$vo['set_view_count']},{$vo['set_mes_count']})">设置数量</a>&nbsp;&nbsp;
                            <a href="#" onclick="editstatus({$vo['id']},{$vo['status']})" >更新状态</a>&nbsp;&nbsp;
                            <a href='{:U("Admin/Message/manage?wall_id=".$vo["id"])}'>留言管理</a>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>

        </form>
        <div class="pagination">{$page}</div>
    </div>

</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/clipboard.min.js"></script>
<script>
    function editmember(id,set_view_count,set_mes_count){
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '设置数量',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['600px', '300px'],
            content: "<?php echo U('Admin/Message/editmember')?>"+'&id='+id+'&set_view_count='+set_view_count+'&set_mes_count='+set_mes_count,
            end: function(){
                location.reload();
            }
        });
    }

    function editstatus(id,status){
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '更新状态',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['600px', '300px'],
            content: "<?php echo U('Admin/Message/editstatus')?>"+'&id='+id+'&status='+status,
            end: function(){
                location.reload();
            }
        });
    }

    function copyone(id) {
        var clipboard = new Clipboard('.btn_'+id);

        clipboard.on('success', function(e) {
            var msg = e.trigger.getAttribute('aria-label');
//            alert(msg);
            console.info('Action:', e.action);
            console.info('Text:', e.text);
            console.info('Trigger:', e.trigger);

            e.clearSelection();
        });
    }


//    function copyToClipboard(text) {
//        window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
//    }
</script>
</body>
</html>